package org.zerocouplage.component.test.view;

import static org.zerocouplage.component.common.ZCComponentFactory.newComponent;

import java.io.IOException;

import org.zerocouplage.component.api.component.ZCButton;
import org.zerocouplage.component.api.component.ZCComponent;
import org.zerocouplage.component.api.component.ZCLabel;
import org.zerocouplage.component.api.component.ZCTextField;
import org.zerocouplage.component.api.layout.ZCBorderLayout;
import org.zerocouplage.component.api.page.ZCPage;
import org.zerocouplage.component.common.exception.ZCCompNotFoundException;
import org.zerocouplage.component.impl.component.ZCAbstractLabel;

import com.zerocouplage.api.controller.IZCManager;
import com.zerocouplage.common.exceptions.ZCExceptionConfig;
import com.zerocouplage.impl.controller.ZCManagerFactory;

public class UserView {

	@SuppressWarnings("unused")
	private IZCManager manager;

	public UserView() {
		manager = ZCManagerFactory.getNewManager(this);
	}

	public Object createGui() throws IOException, ZCCompNotFoundException, ZCExceptionConfig {

		ZCPage page = (ZCPage) newComponent(ZCPage.class);
		page.setTitle("Page login");
		ZCBorderLayout layout = (ZCBorderLayout) newComponent(ZCBorderLayout.class);
		ZCAbstractLabel label = (ZCAbstractLabel) newComponent(ZCLabel.class);
		label.setLabel("Nom");
		ZCTextField textField = (ZCTextField) newComponent(ZCTextField.class);
		ZCButton button = (ZCButton) newComponent(ZCButton.class);
		button.setText("OK");
		layout.setComponentWest(label);
		layout.setComponentEast((ZCComponent) textField);
		layout.setComponentSouth((ZCComponent) button);
		page.setBody(layout);
		return page.display();
	}

	public static void main(String[] args) {
		UserView userView = new UserView();

		
			try {
				System.out.println(userView.createGui());
			} catch (IOException | ZCCompNotFoundException | ZCExceptionConfig e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		
	}
}
